{include file="public/layout" /}

<!--内容管理后台页面-->

<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;min-width:auto;">

<div id="append_parent"></div>

<div id="ajaxwaitid"></div>

<div class="page" style="min-width:auto;box-shadow:none;">

    <div class="flexigrid" style="margin-top: 0px;">

        <div class="mDiv" style="padding: 5px 0px;">

            <div class="ftitle">

                <h3>{$arctype_info.typename|default='全部文档'}</h3>

                <h5>(共{$pager->totalRows}条数据)</h5>

            </div>

            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>

            <form id="searchForm" class="navbar-form form-inline" action="{:url('Archives/index_archives')}" method="get" onsubmit="layer_loading('正在处理');">

                {$searchform.hidden|default=''}
                
                <div class="sDiv">
                    
                    {include file="archives/tags_btn" /}
                    
                    <div class="sDiv2">
                        <input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="标题搜索...">
                        <input type="submit" class="btn" value="搜索">
                    </div>
                </div>
            </form>

             <div class="fbutton" style="float: none;">

                <a href="javascript:;" id="exportData">

                    <div class="add">

                        <span><i class="fa fa-plus"></i>导出数据</span>

                    </div>

                </a>

            </div>

        </div>

        <div class="hDiv">

            <div class="hDivBox">

                <table cellspacing="0" cellpadding="0" style="width: 100%">

                    <thead>

                    <tr>
                        <th class="sign w40" axis="col0">
                            <div class="tc">选择</div>
                        </th>
                        <th abbr="article_title" axis="col3" class="w40">
                            <div class="tc">ID</div>
                        </th>
                        <th abbr="article_title" axis="col3" class="">
                            <div style="text-align: left; padding-left: 10px;" class="">货号</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w100">
                            <div class="tc">所属栏目</div>
                        </th>

                        <th abbr="article_time" axis="col6" class="w50">

                            <div class="tc"><a href="{:getArchivesSortUrl('arcrank')}">审核&nbsp;<i {eq name='$Request.param.orderway' value='asc'}class="fa fa-sort"{else /}class="fa fa-sort"{/eq}></i></a></div>

                        </th>

                        <th abbr="article_time" axis="col6" class="w60">

                            <div class="tc">浏览量</div>

                        </th>

                        {eq name="$arctype_info['current_channel']" value="4"}

                        <th abbr="download_time" axis="col6" class="w60">

                            <div class="tc">下载量</div>

                        </th>

                        {/eq}

                        <th abbr="article_time" axis="col6" class="w100">

                            <div class="tc">发布时间</div>

                        </th>

                        <th axis="col1" class="w180">

                            <div class="tc">操作</div>

                        </th>

                        <th abbr="article_time" axis="col6" class="w60">

                            <div class="tc">排序</div>

                        </th>

                    </tr>

                    </thead>

                </table>

            </div>

        </div>

        <div class="bDiv" style="height: auto;">

            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">

                <table style="width: 100%;">

                    <tbody>

                    {empty name="list"}

                        <tr>

                            <td class="no-data" align="center" axis="col0" colspan="50">

                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录

                            </td>

                        </tr>

                    {else/}

                        {foreach name="list" item="vo" key="k" }

                        <tr>

                            <td class="sign">

                                <div class="tc w40"><input type="checkbox" name="ids[]" value="{$vo.aid}"></div>

                            </td>

                           

                            <td class="sort">

                                <div class="tc w40">

                                    {$vo.aid}

                                </div>

                            </td>

                            <td class="" style="width: 100%;">

                                <div class="tl" style="padding-left: 10px;">

                                    {eq name="'Archives@edit'|is_check_access" value="1"}

                                        {if condition="empty($channelRow[$vo['channel']]['ifsystem'])"}

                                            <a href="{:url('Custom/edit',array('id'=>$vo['aid'],'typeid'=>$Request.param.typeid, 'channel'=>$vo.channel))}" style="{eq name="vo.is_b" value="1"} font-weight: bold;{/eq}">{$vo.title}</a>

                                        {else /}

                                            <a href="{:url($channelRow[$vo['channel']]['ctl_name'].'/edit',array('id'=>$vo['aid'],'typeid'=>$Request.param.typeid))}" style="{eq name="vo.is_b" value="1"} font-weight: bold;{/eq}">{$vo.title}</a>

                                        {/if}

                                    {else /}

                                    {$vo.title}

                                    {/eq}

                                    {assign name='showArcFlagData' value='$vo|showArchivesFlagStr'}

                                    {volist name='$showArcFlagData' id="vo1"}

                                        {eq name='$i' value='1'}<span style="color: red;">[{/eq}

                                        <i style="font-size: 12px;">{$vo1['small_name']}</i>

                                        {eq name='$i' value='$showArcFlagData|count'}]</span>{/eq}
                                    {/volist}
                                </div>
                            </td>


                            <td>
                                <?php
                                    $count = M('archives_message')->where('aid',$vo['aid'])->where('status', 2)->count();
                                    if($count){
                                        echo "<h2 class='red' style='font-size: 20px;margin-top: 10px;margin-right: 220px;'>有消息待处理</h2>";
                                    }
                                ?>
                            </td>
                            <td class="">

                                <div class="w100 tc"><a href="{:url('Archives/index_archives', array('typeid'=>$vo['typeid']))}">{$vo.typename|default='<i class="red">数据出错！</i>'}</a></div>

                            </td>

                            <td>

                                <div class="tc w50">

                                    {if condition="$vo['arcrank'] eq -1"}

                                        <span class="no" {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"} data-typeid="{$vo.typeid}" data-seo_pseudo="{$seo_pseudo}" onclick="changeTableVal('archives','aid','{$vo.aid}','arcrank',this);" {/eq} ><i class="fa fa-ban"></i>否</span>

                                    {else /}

                                        <span class="yes" {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"} data-typeid="{$vo.typeid}" data-seo_pseudo="{$seo_pseudo}" onclick="changeTableVal('archives','aid','{$vo.aid}','arcrank',this);" {/eq} ><i class="fa fa-check-circle"></i>是</span>

                                    {/if}

                                </div>

                            </td>

                            <td>
                                <div class="tc w60">{$vo.click}</div>
                            </td>

                            {eq name="$arctype_info['current_channel']" value="4"}
                            <td>
                                <div class="tc w60">{$vo.downcount}</div>
                            </td>
                            {/eq}

                            <td>
                                <div class="w100 tc">{$vo.add_time|date='Y-m-d',###}</div>
                            </td>

                            <td class="">

                                <div class="w180 tc">

                                    {eq name="'Archives@edit'|is_check_access" value="1"}

                                        {if condition="empty($channelRow[$vo['channel']]['ifsystem'])"}

                                            <a href="{:url('Custom/edit',array('id'=>$vo['aid'],'typeid'=>$Request.param.typeid, 'channel'=>$vo.channel))}" class="btn blue"><i class="fa fa-pencil-square-o"></i>编辑</a>

                                        {else /}

                                            <a href="{:url($channelRow[$vo['channel']]['ctl_name'].'/edit',array('id'=>$vo['aid'],'typeid'=>$Request.param.typeid))}" class="btn blue"><i class="fa fa-pencil-square-o"></i>编辑</a>

                                        {/if}

                                    {/eq}

                                    {eq name="'Archives@del'|is_check_access" value="1"}

                                    <a class="btn red"  href="javascript:void(0);" data-url="{:url('Archives/del')}" data-id="{$vo.aid}" data-deltype="pseudo" onClick="delfun(this);"><i class="fa fa-trash-o"></i>删除</a>

                                    <a href="{$vo.arcurl}" target="_blank" class="btn blue"><i class="fa fa-pencil-square-o"></i>浏览</a>

                                    {/eq}
                                    <a href="javascript:void(0);" class="btn blue" onclick="showImg(this);" data-id="{$vo.aid}" data-url="{:url('Archives/qrcode')}" data-tag="{$vo.arcurl}"><i class="fa fa-pencil-square-o"></i>二维码</a>

                                </div>

                            </td>

                             <td class="sort">
                                <div class="w60 tc">
                                    {eq name="'Archives@edit'|is_check_access" value="1"}
                                    <input type="text" onchange="changeTableVal('archives','aid','{$vo.aid}','sort_order',this);"  size="4"  value="{$vo.sort_order}" />
                                    {else /}
                                    {$vo.sort_order}
                                    {/eq}
                                </div>
                            </td>

                        </tr>

                        {/foreach}

                    {/empty}

                    </tbody>

                </table>

            </div>

            <div class="iDiv" style="display: none;"></div>

        </div>

        <div class="footer-oper">

            <span class="ml15">

                <input type="checkbox" onclick="javascript:$('input[name*=ids]').prop('checked',this.checked);">

            </span>

            <div class="nav-dropup">

                <button class="layui-btn layui-btn-primary dropdown-bt">批量操作<i class="layui-icon layui-icon-up"></i></button>

                <div class="dropdown-menus" style="display:none;">
                    {eq name="'Archives@batch_attr'|is_check_access" value="1"}
                    <a href="javascript:void(0);" onclick="batch_attr(this, 'ids', '批量新增属性');" data-url="{:url('Archives/batch_attr', ['opt'=>'add'])}"><i class="fa fa-plus"></i>新增属性</a>
                    <a href="javascript:void(0);" onclick="batch_attr(this, 'ids', '批量删除属性');" data-url="{:url('Archives/batch_attr', ['opt'=>'del'])}"><i class="fa fa-close"></i>删除属性</a>
                    <hr class="layui-bg-gray">
                    {/eq}

                    {eq name="'Archives@batch_copy'|is_check_access" value="1"}
                    <a href="javascript:void(0);" onclick="func_batch_copy(this, 'ids');" data-url="{:url('Archives/batch_copy', array('typeid'=>$Request.param.typeid))}"><i class="fa fa-copy"></i>复制文档</a>
                    {/eq}

                    {eq name="'Archives@move'|is_check_access" value="1"}
                    <a href="javascript:void(0);" onclick="func_move(this, 'ids');" data-url="{:url('Archives/move', array('typeid'=>$Request.param.typeid))}"><i class="fa fa-hdd-o"></i>移动文档</a>
                    {/eq}

                    {eq name="'Archives@del'|is_check_access" value="1"}
                    <a href="javascript:void(0);" onclick="batch_del(this, 'ids');" data-url="{:url('Archives/del')}" data-deltype="pseudo"><i class="fa fa-close"></i>删除文档</a>
                    {/eq}

                    {eq name="'Archives@check'|is_check_access" value="1"}
                    <a href="javascript:void(0);" onclick="batch_check(this, 'ids');" data-url="{:url('Archives/check')}"><i class="fa fa-check-square-o"></i>审核文档</a>
                    {/eq}

                </div>

            </div>

            {eq name="'RecycleBin@archives_index'|is_check_access" value="1"}
            <a href="{:url('RecycleBin/archives_index')}" class="layui-btn layui-btn-primary" title="回收站">
            	<i class="layui-icon layui-icon-delete"></i>回收站</a>
            {/eq}

        </div>

        <!--分页位置-->

        {$page}

    </div>

</div>

<script type="text/javascript">

    $(document).ready(function(){



        // 表格行点击选中切换

        $('#flexigrid > table>tbody >tr').click(function(){

            $(this).toggleClass('trSelected');

        });



        // 点击刷新数据

        $('.fa-refresh').click(function(){

            location.href = location.href;

        });



        // 选择栏目检索出相应文档列表

        $('#typeid').change(function(){

          $('#searchForm').submit();

        });



        // 批量操作

        $(".dropdown-bt").click(function(){

            $(".dropdown-menus").slideToggle(200);

            event.stopPropagation();

        })

        $(document).click(function(){

            $(".dropdown-menus").slideUp(200);

            event.stopPropagation();

        })

    });



    var aids = '';

    function func_move(obj, name)

    {

        var a = [];

        var k = 0;

        aids = '';

        $('input[name^='+name+']').each(function(i,o){

            if($(o).is(':checked')){

                a.push($(o).val());

                if (k > 0) {

                    aids += ',';

                }

                aids += $(o).val();

                k++;

            }

        })

        if(a.length == 0){

            layer.alert('请至少选择一项', {icon: 2, title:false});

            return;

        }



        var url = $(obj).attr('data-url');

        //iframe窗

        layer.open({

            type: 2,

            title: '移动文档',

            fixed: true, //不固定

            shadeClose: false,

            shade: 0.3,

            maxmin: false, //开启最大化最小化按钮

            area: ['350px', '260px'],

            content: url

        });

    }

    //显示图片
    function showImg(obj){
        var url = $(obj).data('url');
        var tag = $(obj).data('tag');
        var id = $(obj).data('id');
        $.ajax({

            type: "POST",

            url: url,

            data: {tag:tag,id:id},

            dataType: 'json',

            success: function (data) {
                console.log(data);
                layer.closeAll();

                if(data.code == 1){

                    layer.open({

                        type: 1,

                        title: '二维码',

                        fixed: true, //不固定

                        shadeClose: false,

                        shade: 0.3,

                        maxmin: false, //开启最大化最小化按钮

                        area: ['500px', '520px'],

                        content: "<img src= '"+data.data+"'/>"

                    });

                }else{

                    layer.alert(data.msg, {icon: 2, title:false});

                }

            },

            error:function(){

                layer.closeAll();

                layer.alert(ey_unknown_error, {icon: 2, title:false});

            }

        });
    };

    /**

     * 获取修改之前的内容

     */

    function get_aids()

    {

        return aids;

    }



    /**

     * 批量审核

     */

    function batch_check(obj, name) {



        var url = $(obj).attr('data-url');



        var a = [];

        $('input[name^='+name+']').each(function(i,o){

            if($(o).is(':checked')){

                a.push($(o).val());

            }

        })

        if(a.length == 0){

            layer.alert('请至少选择一项', {icon: 2, title:false});

            return;

        }



        // title = '批量审核';

        // btn = ['确定', '取消']; //按钮

        // // 删除按钮

        // layer.confirm(title, {

        //     title: false,

        //     btn: btn //按钮

        // }, function () {

            layer_loading('正在处理');

            $.ajax({

                type: "POST",

                url: url,

                data: {ids:a, _ajax:1},

                dataType: 'json',

                success: function (data) {

                    layer.closeAll();

                    if(data.code == 1){

                        layer.msg(data.msg, {icon: 1});

                        window.location.reload();

                    }else{

                        layer.alert(data.msg, {icon: 2, title:false});

                    }

                },

                error:function(){

                    layer.closeAll();

                    layer.alert(ey_unknown_error, {icon: 2, title:false});

                }

            });

        // }, function (index) {

        //     layer.closeAll(index);

        // });

    }



     $('#exportData').click(function (){

        var keywords = $('input[name="aid"]').val();

        var url = "{:url('Archives/export')}";

        if (keywords == ''){

            window.open(url);

        }else {

            window.open(url+"&keywords="+keywords);
        }

    });




</script>



{include file="public/footer" /}